package com.springboot.activiti.config;

import java.util.ArrayList;
import java.util.List;

import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import com.springboot.activiti.config.activiti.CustomGroupEntityMagagerFactory;
import com.springboot.activiti.config.activiti.CustomUserEntityManagerFactory;

/**
 * 流程引擎初始化时可以加入一些配置参数
 *
 */
@Component
public class MyProcessEngineConfigurationConfigurer implements ProcessEngineConfigurationConfigurer {

	@Autowired
	private CustomUserEntityManagerFactory customUserEntityManagerFactory;
	
	@Autowired
	private CustomGroupEntityMagagerFactory customGroupEntityMagagerFactory;
	
	@Override
	public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
		
		//解决乱码问题 
		processEngineConfiguration.setActivityFontName("宋体");  
        processEngineConfiguration.setLabelFontName("宋体");  
        processEngineConfiguration.setAnnotationFontName("宋体");  
        //自定义activities用户及群组
        List<SessionFactory> customSessionFactories = new ArrayList<SessionFactory>();
        customSessionFactories.add(customUserEntityManagerFactory);
        customSessionFactories.add(customGroupEntityMagagerFactory);
        processEngineConfiguration.setCustomSessionFactories(customSessionFactories);
	}
	
	/*@Bean
	public CustomGroupEntityMagagerFactory customGroupEntityMagagerFactory(){
		return new CustomGroupEntityMagagerFactory();
	}
	
	@Bean
	public CustomUserEntityManagerFactory customUserEntityManagerFactory(){
		return new CustomUserEntityManagerFactory();
	}*/
	
	

}
